package com.huike.business.service.impl;


import com.huike.business.domain.TbBusiness;
import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.mapper.TbBusinessMapper;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 * 
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

    @Autowired
    private TbBusinessMapper tbBusinessMapper;
    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;


    @Override
    public int insertTbBusinessTrackRecord(BusinessTrackVo businessTrackVo) {
        TbBusiness tbBusiness=new TbBusiness();
        BeanUtils.copyBeanProp(tbBusiness,businessTrackVo);
        tbBusiness.setId(businessTrackVo.getBusinessId());
        tbBusiness.setCreateBy(SecurityUtils.getUsername());
        tbBusiness.setCreateTime(DateUtils.getNowDate());
        tbBusinessMapper.updateTbBusiness(tbBusiness);

        TbBusinessTrackRecord tbBusinessTrackRecord=new TbBusinessTrackRecord();
        BeanUtils.copyBeanProp(tbBusinessTrackRecord,businessTrackVo);
        tbBusinessTrackRecord.setCreateBy(SecurityUtils.getUsername());
        tbBusinessTrackRecord.setCreateTime(DateUtils.getNowDate());
        int row = tbBusinessTrackRecordMapper.insertTbBusinessTrackRecord(tbBusinessTrackRecord);
        return row;
    }

    @Override
    public List<TbBusinessTrackRecord> selectTbBusinessTrackRecord(Long business_id) {
        return tbBusinessTrackRecordMapper.selectTbBusinessTrackRecord(business_id);
    }
}
